

<?php
session_start();

$_SESSION['email'] = $_POST['user'];



echo "<input type=text name=sessionuser value='$_SESSION[email]'>";

echo $_SESSION['email'];

?>
<html>


<head>


<body bgcolor=gray>



<h1><marquee bgcolor=orange>Welcome to The SASystem</marquee></h1>





<?php 

//create a connection for the database
$localhost = "localhost";
$user = "root";
$password = "abc123";

$connection = @mysql_connect($localhost, $user, $password);

//
if(!$connection){
 die("Can not connect " . mysql_connect_error());
}
mysql_select_db("sasystemTables", $connection);



$Studentemail_ID = "SELECT * FROM Logins WHERE userID='$_POST[user]' AND password ='$_POST[pass]'";
$result = mysql_query($Studentemail_ID, $connection);




$row = mysql_fetch_array($result);
//echo"<link rel=stylesheet type=text/php href=mysql.php>";
echo "<form action=fortest  method=post>";
echo"<center>";


echo "<input type=hidden name=huser value=" . $row['userID'] . "> <br><br>";
echo "<input type=hidden name=hpass value=" . $row['password'] . "> <br><br>";

echo "Type of user:<input type=text name=Kindofuser value=" . $row['role'] . "> <br><br>";
echo "Username:<input type=text name=user value=" . $row['userID'] . "> <br><br>";
echo "Password:<input type=password name=pass value=" . $row['password'] . "> <br><br>";
echo "<input type=submit name=login value=LOGIN>";
echo "<input type=submit name=signup  value=Sign up>";



echo "</form>";


if(isset($_POST['signup']))
{

header('Location: registration.php');
}
if($_POST['login'] == 'LOGIN')
{
    if(empty($_POST['user']))
    {
    
     echo 'Please put username and password';
    }
            elseif ($_POST['user'] == $row['userID'] && $_POST['pass'] == $row['password'] && $row['role'] == 'Student')

             {    
        

        echo "Student";
         
        //header('Location: student');
         
                 }
       
        elseif ($_POST['user'] == $row['userID'] && $_POST['pass'] == $row['password'] && $row['role'] == 'Admin')

             {    
              
        echo "Admin";
         
        header('Location: adduser');
         
                }

           elseif ($_POST['user'] == $row['userID'] && $_POST['pass'] == $row['password'] && $row['role'] == 'Mentor')

             {
            


    
              
        echo "Mentor";
         
        //header('Location: Mentor');
         
    }
    elseif ($_POST['user'] != $row['userID'] && $_POST['pass'] != $row['password'])

         {

        echo "check your username and password";
         
        //header('Location: student.php');
         
    }

}

 
?>

</center>


</body>
</html>
